//
//  LGOrderSportGoodsCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/11/6.
//  运动评估--商品信息

#import "LGOrderSportGoodsCell.h"

@interface LGOrderSportGoodsCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIButton *titleBtn;
/**   */
@property (nonatomic , strong)UIImageView *photoView;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *priceLabel;
/**   */
@property (nonatomic , strong)UILabel *numberLabel;

@end

@implementation LGOrderSportGoodsCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    if(dataDic.allKeys.count == 0) return;
    [self.photoView sd_setImageWithURL:[NSURL URLWithString:LGNSString(dataDic[@"goods_img_url"])]];
    self.nameLabel.text = LGNSString(dataDic[@"goods_name"]);
    self.priceLabel.text = [NSString stringWithFormat:@"¥%@",dataDic[@"goods_total"]];
    self.numberLabel.text = [NSString stringWithFormat:@"x%@",dataDic[@"goods_num"]];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.baseView];
    [self.baseView addSubview:self.titleBtn];
    [self.baseView addSubview:self.photoView];
    [self.baseView addSubview:self.nameLabel];
    [self.baseView addSubview:self.priceLabel];
    [self.baseView addSubview:self.numberLabel];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.top.equalTo(self.contentView).offset(viewPix(2));
        make.bottom.equalTo(self.contentView).offset(-viewPix(8));
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.photoView.mas_right).offset(viewPix(12));
        make.right.equalTo(self.baseView).offset(-viewPix(12));
        make.top.equalTo(self.photoView);
    }];
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).offset(viewPix(8));
        make.bottom.equalTo(self.baseView).offset(-viewPix(15));
        make.left.equalTo(self.nameLabel);
    }];
    [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.baseView).offset(-viewPix(12));
        make.centerY.equalTo(self.priceLabel);
    }];
}
-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:8];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIButton *)titleBtn{
    if(!_titleBtn){
        _titleBtn = [UIButton buttonWithTitle:@"商品信息" titleFont:LGFontWeight(16, UIFontWeightMedium) textColor:@"#333333" imageName:@"订单详情-订单信息"];
        _titleBtn.frame = CGRectMake(viewPix(16), viewPix(12), viewPix(150), viewPix(22));
        _titleBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        _titleBtn.titleEdgeInsets = UIEdgeInsetsMake(0, viewPix(4), 0, 0);
    }
    return _titleBtn;
}

-(UIImageView *)photoView{
    if(!_photoView){
        _photoView = [[UIImageView alloc]initWithFrame:CGRectMake(viewPix(12), viewPix(48), viewPix(46), viewPix(46))];
        _photoView.cornerRidus = 8;
    }
    return _photoView;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(18) textAlignment:NSTextAlignmentLeft lines:2];
    }
    return _nameLabel;
}


-(UILabel *)priceLabel{
    if(!_priceLabel){
        _priceLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _priceLabel;
}

-(UILabel *)numberLabel{
    if(!_numberLabel){
        _numberLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _numberLabel;
}

@end
